﻿<%@ WebHandler Language="C#" Class="hMenu" %>

using System;
using System.Web;
using System.Data;
using System.Collections.Generic;

using BLL.System;

using CommonLib; 
using System.Web.SessionState;


public class hMenu : IHttpHandler, IRequiresSessionState
{
    public void ProcessRequest (HttpContext context) {
        handle(context);
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }
    private void handle(HttpContext context)
    {
        string action = context.Request.QueryString["action"];
        string result = string.Empty;
        try
        {
            if (context.Session["user"] == null) throw new Exception("登录超时！");
            MenuBO bo = new MenuBO();
            switch (action )
            {
                
                case "get":

                    result = bo.getMenu();
                    break;
                case "add":
                    //
                    result = bo.addMenu(context);
                    break;
                case "edit":
                    //
                    result = bo.editMenu(context);
                    break;
                case "del":
                    //删除
                    result = bo.delMenu(context);
                    break;
                case "up":
                    //上移
                    result = bo.upMenu(context);
                    break;
                case "down":
                    //下移
                    result = bo.downMenu(context);
                    break;
                case "getsub" :     
                    result = bo.getSubMenu();
                    break;
            }
        }
        catch (Exception ex)
        {
            var error = new Entities.Status{ Success=false , Message = ex.Message };
            result = error.ToJson();

        }
        finally
        {
            context.Response.Write(result);
        }
    }


}
